<template>
<view>
<view v-if="details.is_member">
    <view class="banner">
        <view class="banner_backmengceng">
            <image class="banner_headImg" :src="details.head_image"></image>
            <view class="banner_name">{{details.nickname}}</view>
            <view class="banner_title">人气 {{browse?browse:'0'}}丨发布 {{release?release:'0'}}丨粉丝 {{fans?fans:'0'}}</view>
            <view class="banner_style">认证店铺
        <image class="banner_style_img" src="/static/pages/image/zuanshi_icn.png"></image>
            </view>
        </view>
        <image class="banner_backImg" :src="details.store_img?details.store_img:'/static/pages/image/back.png'"></image>
    </view>
    <view v-if="is_cars">
        <view class="name_nav">最新上架</view>
        <view class="shop_modle_border">
            <view v-for="(item, indexs) in cars" :key="indexs" @tap="detile" class="shop_modle" :data-id="item.id">
                <image class="shop_modle_img" :src="item.img_patch"></image>
                <view class="shop_modle_name">{{item.name}}</view>
                <view class="shop_modle_num">{{item.year}} | {{item.km}}万公里</view>
                <view class="shop_modle_price">
                    <text class="shop_modle_price_num">{{item.price}}万</text>
                </view>
            </view>
        </view>
        <view @tap="storetopcars" class="look_modle" v-if="!scanReachBottom">查看更多
      <image class="look_modle_img" src="/static/pages/image/youjiantou_btn.png"></image>
        </view>
        <view class="look_modle" v-if="scanReachBottom">没有更多了
    </view>
    </view>
    <view v-if="is_cars2">
        <view class="name_nav">往日推荐</view>
        <view v-for="(item, indexs) in cars2" :key="indexs" class="modle">
            <view class="tuijian" v-if="item['top_status']">推荐</view>
            <image @tap="detile" class="modle_img" :data-id="item.id" mode="aspectFill" :src="item.img_patch"></image>
            <view @tap="detile" class="message_border" :data-id="item.id">
                <view class="modle_name">
                    <view class="ziying" v-if="item.is_vip==1">认证车商</view>
                    <view class="ziying" v-if="item.uid==0">自营</view>
          {{item.name}} {{item.agelimit==0?'全新车':'车龄 '+item.agelimit+'年'}} {{item.exhaust}} {{item.gearbox==0?'手自一体':''}}{{item.gearbox==1?'手动档':''}}{{item.gearbox==2?'自动档':''}}</view>
                <view class="modle_chexing"> {{item.year}} | {{item.km}}万公里
        </view>
                <view class="modle_price">{{item.price}}万
        </view>
            </view>
        </view>
        <view @tap="storecars2" class="look_modle" v-if="!scanReachBottom2">查看更多
      <image class="look_modle_img" src="/static/pages/image/youjiantou_btn.png"></image>
        </view>
        <view class="look_modle" v-if="scanReachBottom2">没有更多了
    </view>
    </view>
    <view>
        <view class="name_nav">服务保障</view>
        <view v-for="(item, index) in ensure" :key="index" class="baozhang">
            <image class="baozhang_img" :src="item['image']"></image>
            <view class="baozhang_text">{{item['name']}}</view>
        </view>
    </view>
    <view class="page_nav"></view>
</view>
<view v-if="!details.is_member">
    <view class="banner1"></view>
    <view class="banner_modle1">
        <view class="banner_modle_top1">
            <image class="banner_modle_top_img1" :src="details.head_image"></image>
            <view class="banner_modle_top_title1">{{details.nickname}}</view>
            <view class="banner_modle_top_btn1">会员</view>
        </view>
        <view class="banner_modle_down1">
            <view class="banner_modle_down_modle1">
                <view class="banner_modle_down_modle_top1">{{browse?browse:'0'}}</view>
                <view class="banner_modle_down_modle_down1">人气</view>
            </view>
            <view class="banner_modle_down_border1"></view>
            <view class="banner_modle_down_modle1">
                <view class="banner_modle_down_modle_top1">{{release?release:'0'}}</view>
                <view class="banner_modle_down_modle_down1">发布</view>
            </view>
            <view class="banner_modle_down_border1"></view>
            <view class="banner_modle_down_modle1">
                <view class="banner_modle_down_modle_top1">{{fans?fans:'0'}}</view>
                <view class="banner_modle_down_modle_down1">粉丝</view>
            </view>
        </view>
    </view>
</view>
<view class="modle_border" v-if="!details.is_member">
    <view v-for="(item, indexs) in cars" :key="indexs" class="modle">
        <view class="tuijian" v-if="item['top_status']">推荐</view>
        <image @tap="detile" class="modle_img" :data-id="item.id" mode="aspectFill" :src="item.img_patch"></image>
        <view @tap="detile" class="message_border" :data-id="item.id">
            <view class="modle_name">
                <view class="ziying" v-if="item.is_vip==1">认证车商</view>
                <view class="ziying" v-if="item.uid==0">自营</view>
        {{item.name}} {{item.agelimit==0?'全新车':'车龄 '+item.agelimit+'年'}} {{item.exhaust}} {{item.gearbox==0?'手自一体':''}}{{item.gearbox==1?'手动档':''}}{{item.gearbox==2?'自动档':''}}</view>
            <view class="modle_chexing"> {{item.time}} | {{item.km}}万公里
      </view>
            <view class="modle_price">{{item.price}}万
      </view>
        </view>
    </view>
    <view class="end_none" v-if="scanReachBottom">没有更多了...</view>
</view>
<view class="nav_nav"></view>
<view class="btm_nav">
    <view @tap="shouyewdj_btn" class="btm_nav_small">
        <image class="btm_nav_small_img" src="/static/pages/image/shouyewdj_btn.png"></image>
        <view class="btm_nav_small_title">首页</view>
    </view>
    <view @tap="follow" class="btm_nav_small">
        <image class="btm_nav_small_img" src="/static/pages/image/guanzhu_btn.png" v-if="follow_status"></image>
        <image class="btm_nav_small_img" src="/static/pages/image/yiguanzhu_btn.png" v-if="!follow_status"></image>
        <view class="btm_nav_small_title">关注</view>
    </view>
    <view @tap="message" class="btm_nav_small">
        <image class="btm_nav_small_img" src="/static/pages/image/liuyan_btn.png"></image>
        <view class="btm_nav_small_title">留言</view>
    </view>
    <button @tap="makephone" class="btm_nav_big_index">联系车主</button>
    <button class="btm_nav_big_second" open-type="share">立即分享</button>
</view>
</view>
</template>

<script>
var app = getApp(),
    leftid = 2,
    page2 = 2;

export default {
  data() {
    return {
      fans: 0,
      release: 0,
      browse: 0,
      cars: [],
      cars2: [],
      details: [],
      is_cars: !0,
      is_cars2: !0,
      scanReachBottom: !1,
      scanReachBottom2: !1,
      follow_status: !0,
      ensure: [],
      appscene: 0,
      store_uid: "",
      isShow: "",
      follow: ""
    };
  },

  components: {},
  props: {},
  onLoad: function (a) {
    1007 != app.globalData.data.appscene && 1008 != app.globalData.data.appscene && 1011 != app.globalData.data.appscene && 1012 != app.globalData.data.appscene && 1013 != app.globalData.data.appscene && 1014 != app.globalData.data.appscene || this.setData({
      appscene: 1
    });
    var s = this;
    if (a.scene) var t = a.scene;else t = a.uid;
    t || (t = app.globalData.getuid()), s.setData({
      store_uid: t
    });
    s = this;
    app.globalData.util.request({
      url: "entry/wxapp/Api",
      data: {
        m: "monai_market",
        uid: app.globalData.getuid(),
        thatuid: t,
        r: "sale.index.getstoredetail"
      },
      success: function (a) {
        console.log(a), wx.setNavigationBarTitle({
          title: a.data.data.detail.nickname
        }), console.log(a.data.data.ensure), s.setData({
          fans: a.data.data.fans,
          release: a.data.data.release,
          browse: a.data.data.browse,
          details: a.data.data.detail,
          cars: a.data.data.cars,
          cars2: a.data.data.cars2,
          follow_status: a.data.data.iffollow,
          ensure: a.data.data.ensure
        });
        var t = a.data.data.cars.length;
        console.log(t), t < 1 ? s.setData({
          is_cars: !1
        }) : t < 4 && s.setData({
          scanReachBottom: !0
        });
        var e = a.data.data.cars2.length;
        e < 1 ? s.setData({
          is_cars2: !1
        }) : e < 5 && s.setData({
          scanReachBottom2: !0
        });
      }
    });
  },
  onReachBottom: function () {
    var s = this,
        o = s.cars;

    if (!s.scanReachBottom) {
      if (s.details.is_member) return !1;
      console.log(s.store_uid), app.globalData.util.request({
        url: "entry/wxapp/Api",
        data: {
          m: "monai_market",
          leftid: leftid,
          r: "sale.index.getstoredetail",
          thatuid: s.store_uid
        },
        success: function (a) {
          if ("null" != a.data.data) {
            var t = a.data.data.length;

            if (leftid++, 0 < t) {
              for (var e = 0; e < t; e++) o.push(a.data.data[e]);

              s.setData({
                cars: o
              });
            } else s.setData({
              scanReachBottom: !0
            });
          }
        }
      });
    }
  },
  onShareAppMessage: function () {
    return {
      title: this.details.nickname,
      path: "/pages/store/index?uid=" + this.store_uid
    };
  },
  methods: {
    detile: function (a) {
      console.log(a), wx.navigateTo({
        url: "/pagesA/home/carMessage/carMessage?id=" + a.currentTarget.dataset.id
      });
    },
    message: function () {
      wx.navigateTo({
        url: "/pagesA/home/jubao/jubao?car_uid=" + this.store_uid + "&form_type=1"
      });
    },
    report: function () {
      wx.navigateTo({
        url: "/pagesA/home/jubao/jubao?car_uid=" + this.store_uid + "&form_type=2"
      });
    },
    makephone: function () {
      this.details && this.details.phone ? wx.makePhoneCall({
        phoneNumber: this.details.phone
      }) : wx.showModal({
        content: "该商家暂未没有留下联系方式",
        showCancel: !1
      });
    },
    follow: function () {
      var t = this;
      app.globalData.util.getUserInfo(function (a) {
        a.memberInfo || that.setData({
          isShow: !0
        });
      }), console.log(this.store_uid), app.globalData.util.request({
        url: "entry/wxapp/Api",
        data: {
          m: "monai_market",
          r: "me.follow",
          uid: app.globalData.getuid(),
          type: 1,
          ucar_id: this.store_uid
        },
        cachetime: "0",
        success: function (a) {
          t.setData({
            follow_status: !t.follow_status,
            follow: a.data.data
          });
        }
      });
    },
    storetopcars: function () {
      var s = this,
          o = s.cars;
      s.scanReachBottom || app.globalData.util.request({
        url: "entry/wxapp/Api",
        data: {
          m: "monai_market",
          leftid: leftid,
          is_vip: 1,
          r: "sale.index.getstoredetail",
          thatuid: s.store_uid
        },
        success: function (a) {
          if ("null" != a.data.data) {
            var t = a.data.data.length;

            if (leftid++, 0 < t) {
              for (var e = 0; e < t; e++) o.push(a.data.data[e]);

              t < 4 && s.setData({
                scanReachBottom: !0
              }), s.setData({
                cars: o
              });
            } else s.setData({
              scanReachBottom: !0
            });
          } else s.setData({
            scanReachBottom: !0
          });
        }
      });
    },
    storecars2: function () {
      var s = this,
          o = s.cars2;
      s.scanReachBottom2 || app.globalData.util.request({
        url: "entry/wxapp/Api",
        data: {
          m: "monai_market",
          leftid: page2,
          is_vip: 2,
          r: "sale.index.getstoredetail",
          thatuid: s.store_uid
        },
        success: function (a) {
          if ("null" != a.data.data) {
            var t = a.data.data.length;

            if (page2++, 0 < t) {
              for (var e = 0; e < t; e++) o.push(a.data.data[e]);

              t < 5 && s.setData({
                scanReachBottom2: !0
              }), s.setData({
                cars2: o
              });
            } else s.setData({
              scanReachBottom2: !0
            });
          } else s.setData({
            scanReachBottom2: !0
          });
        }
      });
    },
    shouyewdj_btn: function () {
      console.log(123), wx.switchTab({
        url: "/pages/index/index"
      }), app.globalData.data.appscene = 0;
    }
  }
};
</script>
<style>
@import "./index.css";
</style>